package com.ruoyi.scale.model;

import lombok.Data;

import java.util.*;

@Data
public class GrowthNormDataWrap {
    //体重
    public List<GrowthNormData>  boyWeight;
    public List<GrowthNormData> girlWeight;
    //身高
    public List<GrowthNormData> boyHeight ;
    public List<GrowthNormData> girlHeight;
    //身长的体重
    public List<GrowthNormData> boyBodyLength ;
    public List<GrowthNormData> girlBodyLength;
    //bmi
    public List<GrowthNormData> boyBmi;
    public List<GrowthNormData> girlBmi;
    //头围
    public List<GrowthNormData> boyTw;
    public List<GrowthNormData> girlTw;
    //胸围
    public List<GrowthNormData> boyXw;
    public List<GrowthNormData> girlXw;


    public List<GrowthNormData> getWeight(int sex){
        return sex == 1 ? boyWeight :girlWeight;
    }

    public List<GrowthNormData> getHeight(int sex){
        return sex == 1 ? boyHeight :girlHeight;
    }

    public List<GrowthNormData> getBodyLength(int sex){
        return sex == 1 ? boyBodyLength :girlBodyLength;
    }

    public List<GrowthNormData> getBmi(int sex){
        return sex == 1 ? boyBmi :girlBmi;
    }

    public List<GrowthNormData> getTw(int sex){
        return sex == 1 ? boyTw :girlTw;
    }

    public List<GrowthNormData> getXw(int sex){
        return sex == 1 ? boyXw :girlXw;
    }

    public GrowthNormData matchNorm(Double keyVal, List<GrowthNormData> list){
        if(list == null){
            return null;
        }
        double keyValTemp = keyVal.doubleValue();
        for (int i = 0; i < list.size(); i++) {
            double listKeyValTemp = list.get(i).getKeyVal().doubleValue();
            if(listKeyValTemp  == keyValTemp){
                return list.get(i);
            }
            if(listKeyValTemp > keyValTemp){
                if(i == 0){
                    return null;
                }
                return list.get(i -1);
            }
        }
        return null;
    }





   ////////////////////////////////

    private Map<String,List<GrowthNormData>> normData;


    /**boyAgeWeightPer7 7岁以下男童年龄别体重的百分位数值**/
    public List<GrowthNormData> queryBoyAgeWeightPer7(){
        return normData.get("boyAgeWeightPer7");
    }
    /**girlAgeWeightPer7 7岁以下女童年龄别体重的百分位数值**/
    public List<GrowthNormData> queryGirlAgeWeightPer7(){
        return normData.get("girlAgeWeightPer7");
    }
    /**boyAgeHeightPer7 7岁以下男童年龄别身长/身高的百分位数值**/
    public List<GrowthNormData> queryBoyAgeHeightPer7(){
        return normData.get("boyAgeHeightPer7");
    }
    /**girlAgeHeightPer7 7岁以下女童年龄别身长/身高的百分位数值**/
    public List<GrowthNormData> queryGirlAgeHeightPer7(){
        return normData.get("girlAgeHeightPer7");
    }
    /**boyHeightWeightPer0_2 0～2岁以下男童身长别体重的百分位数值**/
    public List<GrowthNormData> queryBoyHeightWeightPer0_2(){
        return normData.get("boyHeightWeightPer0_2");
    }
    /**girlHeightWeightPer0_2 0～2岁以下女童身长别体重的百分位数值**/
    public List<GrowthNormData> queryGirlHeightWeightPer0_2(){
        return normData.get("girlHeightWeightPer0_2");
    }
    /**boyHeightWeightPer2_7 2～7岁以下男童身高别体重的百分位数值**/
    public List<GrowthNormData> queryBoyHeightWeightPer2_7(){
        return normData.get("boyHeightWeightPer2_7");
    }
    /**girlHeightWeightPer2_7 2～7岁以下女童身高别体重的百分位数值**/
    public List<GrowthNormData> queryGirlHeightWeightPer2_7(){
        return normData.get("girlHeightWeightPer2_7");
    }
    /**boyAgeBmiPer7 7岁以下男童年龄别 BMI 的百分位数值**/
    public List<GrowthNormData> queryBoyAgeBmiPer7(){
        return normData.get("boyAgeBmiPer7");
    }
    /**girlAgeBmiPer7 7岁以下女童年龄别BMI的百分位数值**/
    public List<GrowthNormData> queryGirlAgeBmiPer7(){
        return normData.get("girlAgeBmiPer7");
    }
    /**boyAgeTwPer0_3 0～3岁男童年龄别头围的百分位数值**/
    public List<GrowthNormData> queryBoyAgeTwPer0_3(){
        return normData.get("boyAgeTwPer0_3");
    }
    /**girlAgeTwPer0_3 0～3岁女童年龄别头围的百分位数值**/
    public List<GrowthNormData> queryGirlAgeTwPer0_3(){
        return normData.get("girlAgeTwPer0_3");
    }
    /**boyAgeWeightSd7 7岁以下男童年龄别体重的标准差数值**/
    public List<GrowthNormData> queryBoyAgeWeightSd7(){
        return normData.get("boyAgeWeightSd7");
    }
    /**girlAgeWeightSd7 7岁以下女童年龄别体重的标准差数值**/
    public List<GrowthNormData> queryGirlAgeWeightSd7(){
        return normData.get("girlAgeWeightSd7");
    }
    /**boyHeightSd7 7岁以下男童年龄别身长/身高的标准差数值**/
    public List<GrowthNormData> queryBoyAgeHeightSd7(){
        return normData.get("boyAgeHeightSd7");
    }
    /**girlHeightSd7 7岁以下女童年龄别身长/身高的标准差数值**/
    public List<GrowthNormData> queryGirlAgeHeightSd7(){
        return normData.get("girlAgeHeightSd7");
    }
    /**boyHeightWeightSd0_2 0～2岁以下男童身长别体重的标准差数值**/
    public List<GrowthNormData> queryBoyHeightWeightSd0_2(){
        return normData.get("boyHeightWeightSd0_2");
    }
    /**girlHeightWeightSd0_2 0～2岁以下女童身长别体重的标准差数值**/
    public List<GrowthNormData> queryGirlHeightWeightSd0_2(){
        return normData.get("girlHeightWeightSd0_2");
    }
    /**boyHeightWeightSd2_7 2～7岁以下男童身高别体重的标准差数值**/
    public List<GrowthNormData> queryBoyHeightWeightSd2_7(){
        return normData.get("boyHeightWeightSd2_7");
    }
    /**girlHeightWeightSd2_7 2～7岁以下女童身高别体重的标准差数值**/
    public List<GrowthNormData> queryGirlHeightWeightSd2_7(){
        return normData.get("girlHeightWeightSd2_7");
    }
    /**boyAgeBmiSd7 7岁以下男童年龄别BMI的标准差数值**/
    public List<GrowthNormData> queryBoyAgeBmiSd7(){
        return normData.get("boyAgeBmiSd7");
    }
    /**girlAgeBmiSd7 7岁以下女童年龄别 BMI 的标准差数值**/
    public List<GrowthNormData> queryGirlAgeBmiSd7(){
        return normData.get("girlAgeBmiSd7");
    }
    /**boyAgeTwSd0_3 0～3岁男童年龄别头围的标准差数值**/
    public List<GrowthNormData> queryBoyAgeTwSd0_3(){
        return normData.get("boyAgeTwSd0_3");
    }
    /**girlAgeTwSd0_3 0～3岁女童年龄别头围的标准差数值**/
    public List<GrowthNormData> queryGirlAgeTwSd0_3(){
        return normData.get("girlAgeTwSd0_3");
    }
    public List<GrowthNormData> ageWeightPer7(int sex){
        return sex == 1 ? queryBoyAgeWeightPer7() : queryGirlAgeWeightPer7();
    }
    public List<GrowthNormData> ageHeightPer7(int sex){
        return sex == 1 ? queryBoyAgeHeightPer7() : queryGirlAgeHeightPer7();
    }
    public List<GrowthNormData> heightWeightPer0_2(int sex){
        return sex == 1 ? queryBoyHeightWeightPer0_2() : queryGirlHeightWeightPer0_2();
    }
    public List<GrowthNormData> heightWeightPer2_7(int sex){
        return sex == 1 ? queryBoyHeightWeightPer2_7() : queryGirlHeightWeightPer2_7();
    }
    public List<GrowthNormData> ageBmiPer7(int sex){
        return sex == 1 ? queryBoyAgeBmiPer7() : queryGirlAgeBmiPer7();
    }
    public List<GrowthNormData> ageTwPer0_3(int sex){
        return sex == 1 ? queryBoyAgeTwPer0_3() : queryGirlAgeTwPer0_3();
    }
    public List<GrowthNormData> ageWeightSd7(int sex){
        return sex == 1 ? queryBoyAgeWeightSd7() : queryGirlAgeWeightSd7();
    }
    public List<GrowthNormData> ageAgeHeightSd7(int sex){
        return sex == 1 ? queryBoyAgeHeightSd7() : queryGirlAgeHeightSd7();
    }
    public List<GrowthNormData> heightWeightSd0_2(int sex){
        return sex == 1 ? queryBoyHeightWeightSd0_2() : queryGirlHeightWeightSd0_2();
    }
    public List<GrowthNormData> heightWeightSd2_7(int sex){
        return sex == 1 ? queryBoyHeightWeightSd2_7() : queryGirlHeightWeightSd2_7();
    }
    public List<GrowthNormData> ageBmiSd7(int sex){
        return sex == 1 ? queryBoyAgeBmiSd7() : queryGirlAgeBmiSd7();
    }
    public List<GrowthNormData> ageTwSd0_3(int sex){
        return sex == 1 ? queryBoyAgeTwSd0_3() : queryGirlAgeTwSd0_3();
    }


    public static void main(String[] args) {


//        List<GrowthPerNormData> gs = new ArrayList<>();
//        for (int i = 0; i < 100; i+=2) {
//            int finalI = i;
//            gs.add(new GrowthPerNormData(){
//                {
//                    setKeyVal(Double.valueOf(finalI));
//                }
//            });
//        }
//
//        GrowthPerNormData growthPerNormData = new GrowthNormDataWrap().matchNorm(97d, gs);
//
//
//        System.out.println(growthPerNormData);
    }
}
